#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "file.h"

LIST L, L1;

FILE *fp, *fp1;

int main()
{
    int x, p = 0, ok;
    char buffer[SIZE];

    fp = fopen("words.txt", "r+");
    fp1 = fopen("words1.txt", "w");

    while (x != EOF)
    {
        p = 0;
        ok = 0;
        while ((x = fgetc(fp)) != ' ' && x != EOF && x != '\n')
        {
            buffer[p] = x;
            ++p;
            buffer[p] = '\0';
            ok = 1;
        }

        if (iterate_n_test(&L, buffer, ok) == 0)
            insert_to_tail(buffer, p, &L);
    }

    iterate_n_sort(&L);

    iterate_n_print(&L);

    fclose(fp);
    fclose(fp1);

    return 0;
}

